package com.qf.listener;

import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

//@Component
//@RocketMQMessageListener(consumerGroup="consumer-group1",topic="test2")
public class RocketMQListener1 implements RocketMQListener<Message> {
    @Override
    public void onMessage(Message message) {
        try {
            byte[] body = message.getBody();
            System.out.println("消费者1：" + new String(body,"utf-8"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
